@if (control && control.dirty && !control.valid) {

    @for (error of errorKeys; track error) {

        @if (control.hasError(error)) {
            <div class="core-input-error">
                @if (error !== 'pattern') {

                    @if (errorMessages && errorMessages[error]) {
                        <span>
                            @if (error === 'required') {
                                <ion-icon name="fas-circle-exclamation" aria-hidden="true" />
                            }
                            {{ errorMessages[error] | translate }}
                        </span>
                    } @else if ((!errorMessages || !errorMessages[error]) && error === 'max' && control.errors?.max) {
                        <span>
                            {{ 'core.login.invalidvaluemax' | translate:{$a: control.errors!.max.max} }}
                        </span>
                    } @else if ((!errorMessages || !errorMessages[error]) && error === 'min' && control.errors?.min) {
                        <span>
                            {{ 'core.login.invalidvaluemin' | translate:{$a: control.errors!.min.min} }}
                        </span>
                    }

                } @else {
                    <ng-container *ngIf="getPatternErrorMessage() as errorMessage">
                        <span>{{ errorMessage | translate }}</span>
                    </ng-container>
                }
            </div>
        }
    }
}
@if (errorText) {
    <div class="core-input-error" aria-live="assertive">{{ errorText }}</div>
}
